package com.xuln.common.freemarker;

import java.io.IOException;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import freemarker.template.Template;
import freemarker.template.TemplateException;

public class FreeMarkerService {
	@Resource
	private FreeMarkerConfigurer freeMarkerConfigurer;

	@SuppressWarnings("unchecked")
	public String processTemplateIntoString(String templateName, Map model) throws IOException, TemplateException {
		Template template = freeMarkerConfigurer.getConfiguration().getTemplate(templateName);
		return FreeMarkerTemplateUtils.processTemplateIntoString(template, model);

	}
}
